<template>
	<div>
		<el-card>
			<div slot="header">
				<span>策略查询</span>
			</div>
			<el-row>
				<el-form label-width="auto">
					<el-col :span="6">
						<el-form-item label="请输入项目名称:">
							<el-input v-model="taskName" placeholder="请输入方案名称 支持模糊查询" clearable />
						</el-form-item>
					</el-col>
					<el-col :span="18">
						<el-form-item style="text-align: right; margin-right: 15px">
							<el-button type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
							<el-button icon="el-icon-refresh-right" @click="reset">重置</el-button>
						</el-form-item>
					</el-col>
				</el-form>
			</el-row>
		</el-card>
		<div class="base-view" style="margin-top: 20px">
			<el-table :data="tableData" style="width: 100%" border stripe height="300px">
				<el-table-column v-for="(item, key) in columnList" :key="key" :prop="item.prop" :label="item.label" :min-width="120" :fixed="[0, 1].some(i => i === key)" />
			</el-table>
			<div class="base-pagination">
				<el-pagination :total="total" background layout="total, sizes, prev, pager, next, jumper" :page-size="pageSize" :page-sizes="[10, 20, 50, 100]" :current-page="currentPage" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
			</div>
		</div>
	</div>
</template>

<script>
import axios from "axios";

export default {
	data() {
		return {
			total: 0,
			currentPage: 1,
			pageSize: 10,
			taskName: "",
			pageNum: "1",
			loading: false,
			tableData: null,
			columnList: [
				{ prop: "taskName", label: "方案名称" },
				{ prop: "replenishScene", label: "场景" },
				{ prop: "perfectBranch", label: "完美分支" },
				{ prop: "wuLingBranch", label: "五菱分支" },
				{ prop: "multiLevelWarehouse", label: "多层级仓网策略" },
				{ prop: "useUpload", label: "线下poc" },
				{ prop: "useBod", label: "线下poc-bod" },
				{ prop: "inOutRule", label: "进销存策略" },
				{ prop: "fulfillRule", label: "履约策略" },
				{ prop: "boFulfillRule", label: "BO履约策略" },
				{ prop: "fulfillSource", label: "履约数据来源" },
				{ prop: "sourceFindingRule", label: "寻源策略" },
				{ prop: "fillForZeroInv", label: "期初库存策略" },
				{ prop: "forecastRoll", label: "预测日滚动" },
				{ prop: "goodsClassify", label: "商品分类管理" },
				{ prop: "replenishTrigger", label: "补货点策略" },
				{ prop: "warehousePocAllocateType", label: "补货分配策略" },
				{ prop: "replenishCalRule", label: "补货量策略" },
				{ prop: "safetyStockCalRule", label: "安全库存策略" },
				{ prop: "useCartonSpecFix", label: "箱规修正" },
				{ prop: "boReplenish", label: "bo补调单下单时间" },
				{ prop: "tradeLayout", label: "商品布局" },
				{ prop: "inventoryShuffle", label: "期初库存洗牌" },
				{ prop: "useUpFlowPoFix", label: "上游库存修正" },
				{ prop: "useMinOrderQty", label: "最小起订量修正" }
			]
		};
	},
	methods: {
		onSubmit() {
			this.loading = true;
			axios({
				method: "post",
				url: "http://localhost:8088/api/project/getStrategyOptions",
				data: {
					pageNum: this.currentPage,
					pageSize: this.pageSize,
					taskName: this.taskName
				}
			})
				.then(response => {
					this.loading = false;
					if (response.status === 200) {
						this.tableData = response.data.data.list;
						this.total = response.data.data.total;
						// eslint-disable-next-line no-empty
					} else {
					}
				})
				.catch(() => {});
		},
		handleCurrentChange(val) {
			this.currentPage = val;
			this.onSubmit();
		},
		handleSizeChange(val) {
			this.pageSize = val;
		},
		reset() {
			this.taskName = "";
		}
	}
};
</script>

<style scoped></style>
